﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace dzs.Web.stype
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int stid=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(stid);
				}
			}
		}
			
	private void ShowInfo(int stid)
	{
		dzs.BLL.stype bll=new dzs.BLL.stype();
		dzs.Model.stype model=bll.GetModel(stid);		
		this.txtstname.Text=model.stname;
		this.txtstdes.Text=model.stdes;

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtstname.Text.Trim().Length==0)
			{
				strErr+="仓库类型名称不能为空！\\n";	
			}
			if(this.txtstdes.Text.Trim().Length==0)
			{
				strErr+="仓库类型描述不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int stid=0;
            if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
            {
                stid = (Convert.ToInt32(Request.Params["id"]));                
            }
			string stname=this.txtstname.Text;
			string stdes=this.txtstdes.Text;
			dzs.Model.stype model=new dzs.Model.stype();
			model.stid=stid;
			model.stname=stname;
			model.stdes=stdes;

			dzs.BLL.stype bll=new dzs.BLL.stype();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","List.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("List.aspx");
        }
    }
}
